package org.budo.support.spring.session.filter.factory;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.session.ExpiringSession;
import org.springframework.session.MapSessionRepository;
import org.springframework.session.SessionRepository;
import org.springframework.session.web.http.SessionRepositoryFilter;

/**
 * @author limingwei2
 */
public class SessionRepositoryFilterFactoryBean implements FactoryBean<SessionRepositoryFilter<ExpiringSession>> {
    private SessionRepository<ExpiringSession> sessionRepository = new MapSessionRepository();

    public void setSessionRepository(SessionRepository<ExpiringSession> sessionRepository) {
        this.sessionRepository = sessionRepository;
    }

    public SessionRepositoryFilter<ExpiringSession> getObject() throws Exception {
        return new SessionRepositoryFilter<ExpiringSession>(sessionRepository);
    }

    public Class<?> getObjectType() {
        return SessionRepositoryFilter.class;
    }

    public boolean isSingleton() {
        return true;
    }
}